#include <stdio.h>
int main()
{
    int a = 0, b = 0;
    scanf("%d,%d", &a, &b);
    int r;
    while (r != 0)
    {
        r = a % b;
        a = b;
        b = r;
    }
    printf("%d", b);
    return 0;
}